import requests;
from lxml import etree;

baidu=requests.get('https://www.baidu.com');
baidu.encoding='utf-8';#不加这行，会有乱码
html=etree.HTML(baidu.text);

logo_url=html.xpath('//*[@id="lg"]/img/@src')[0];
logo_url='http:'+logo_url;
print(logo_url);

logo=requests.get(logo_url);
file=open('10logo.png','wb');
file.write(logo.content);
file.close;